<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>

<html>
<head>
<title>家长管理</title>
<meta name="decorator" content="default" />
<%@ include file="/WEB-INF/views/include/dialog.jsp"%>
<script type="text/javascript">
$(document).ready(function() {
	$("#btnExport").click(function(){
		top.$.jBox.confirm("确认要导出学生数据吗？","系统提示",function(v,h,f){
			if(v=="ok"){
				$("#searchForm").attr("action","${ctx}/dd/ddParent/export");
				$("#searchForm").submit();
			}
		},{buttonsFocus:1});
		top.$('.jbox-body .jbox-icon').css('top','55px');
	});
	$("#btnImport").click(function(){
		$.jBox($("#importBox").html(), {title:"导入数据", buttons:{"关闭":true}, 
			bottomText:"导入文件不能超过5M，仅允许导入“xls”或“xlsx”格式文件！"});
	});
});
	function page(n,s){
		if(n) $("#pageNo").val(n);
		if(s) $("#pageSize").val(s);
		$("#searchForm").attr("action","${ctx}/dd/ddParent/list");
		$("#searchForm").submit();
    	return false;
    };
    function setDowmUrl(){
		var url='${ctxStatic}'+"/xls/家长表.xlsx";
		location.href =url;
    };
	function showDialog(value) {
		$("#info").val();
		var title;
		if(value==1){
			title="微信绑定";
		}else if(value==2){
			title="卡号绑定";
		}
		$("#dialog").dialog({
			modal : true
		}, {
			'title' : title
		}, {
			show : {
				effect : 'drop',
				direction : 'up'
			}
		}, {
			width : "500"
		}, {
			height : "200"
		});
	};
</script>
</head>
<body>

<div id="importBox" class="hide">
		<form id="importForm" action="${ctx}/dd/ddParent/import" method="post" enctype="multipart/form-data"
			class="form-search" style="padding-left:20px;text-align:center;" onsubmit="loading('正在导入，请稍等...');"><br/>
			<input id="uploadFile" name="file" type="file" style="width:330px"/><br/><br/>　　
			<input id="btnImportSubmit" class="btn btn-primary" type="submit" value="   导    入   "/>
			<%-- <a href="${ctx}/dd/ddStudent/import/template">下载模板</a> --%>
				<a id="dowmTable" href="javascript:;" onclick="setDowmUrl();">下载模板</a>
		</form>
	</div>
	
	
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/dd/ddParent/">家长列表</a></li>
		<shiro:hasPermission name="dd:ddParent:edit">
			<li><a href="${ctx}/dd/ddParent/form">添加</a></li>
		</shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="ddParent"
		action="${ctx}/dd/ddParent/" method="post"
		class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}" />
		<input id="pageSize" name="pageSize" type="hidden"
			value="${page.pageSize}" />
		<ul class="ul-form">
			<li><label>家长姓名：</label> <form:input path="name"
					htmlEscape="false" maxlength="50" class="input-medium" /></li>
			<li><label>身份证：</label> <form:input path="idCard"
					htmlEscape="false" maxlength="50" class="input-medium" /></li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary"
				type="submit" value="查询" />
				<input id="btnImport" class="btn btn-primary" type="button" value="导入"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}" />
	<table id="contentTable"
		class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>家长姓名</th>
				<th>民族</th>
				<th>工作单位</th>
				<th>手机号码</th>
				<th>微信号</th>
				<th>是否为监护人</th>
				<th>卡号</th>
				<shiro:hasPermission name="dd:ddParent:edit">
					<th>操作</th>
				</shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
			<c:forEach items="${page.list}" var="ddParent">
				<tr>
					<td><a href="${ctx}/dd/ddParent/form?id=${ddParent.id}"
						title="查看"> ${ddParent.name} </a></td>
					<td>${ddParent.nation}</td>
					<td>${ddParent.workUnits}</td>
					<td>${ddParent.mobile}</td>
					<td>${fns:isWeiXin(ddParent.createBy.id)}</td>
					<td>
					${fns:getDictLabel(ddParent.isGuardian, 'yes_no',1)}</td>
					<td>${ddParent.cardNumber}</td>
					<shiro:hasPermission name="dd:ddParent:edit">
						<td><a href="${ctx}/dd/ddParent/form?id=${ddParent.id}"
							title="家长信息管理">修改</a> 
							<a href="javascript:;" onclick="showDialog(1);" title="微信绑定">绑定微信</a>
							<a href="javascript:;" onclick="showDialog(2);" title="卡号绑定">绑定卡号</a>
							<a href="${ctx}/dd/ddParent/delete?id=${ddParent.id}" title="删除"
							onclick="return confirmx('确认要删除该单表吗？', this.href)">删除</a></td>
					</shiro:hasPermission>
				</tr>
			</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>



	<div id="dialog" style="display:none;">
		<form class="form-horizontal" role="form" id="f_bind"
			action="${ctx}/dd/ddParent/bind" method="post">
			<input type="hidden" id="" name="" />
			<div class="clearfix" style="height: 20px"></div>
			<div class="control-group">
				<label class="control-label"><b
					style="color: red; font-size: large">*</b>绑定输入:</label>
					 &nbsp; <input class="input-medium" id="info" name="info"
					placeholder="请输入" required="required" min="0" />
			</div>
			<div class="clearfix" style="height: 10px"></div>
			<div class="control-group" style="width: 15%; margin:auto;">
				<input type=button id="bindSubmit" class="" value="提交" />
			</div>
		</form>
	</div>
	<script>
		$(function() {
			$('#bindSubmit').click(function() {//点击按钮提交
				$.ajax({
					url : "${ctx}/dd/ddParent/bind",
					data : $("#f_bind").serialize(),
					type : "post",
					success : function(data) {//ajax返回的数据
						alert(data);
						$("#dialog").dialog('close');
					},
					error : function(data) {//ajax返回的数据
						alert(data);
						$("#dialog").dialog('close');
					}
				});
			});

		});
	</script>
</body>
</html>